﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShopOnline.Models;
using ShopOnline.Models.DAL;

namespace ShopOnline.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        private ShopOnlineDBDataContext dataContext;
        private DAL_Press pressRepository;
        private DAL_Catelogy CatelogyRepositpry;
        private DAL_ProjectCatelogy ProjectCatelogyRepository;
        private DAL_ProductCatelogy ProductCatelogyRepository;
        private DAL_Advert AdvertRepository;
        private DAL_LinkWebsite LinkWebsiteRepository;
        private DAL_Project ProjectRepository;
        private DAL_Product ProductRepository;
        private DAL_Work WorksRepository;
        private DAL_Partner PartnerRepository;
        public static int productCateId;
        private DAL_AttachCatelogy AttachCatelogyRepository;
        public HomeController()
        {
            dataContext = new ShopOnlineDBDataContext();
            pressRepository = new DAL_Press();
            CatelogyRepositpry = new DAL_Catelogy();
            ProjectCatelogyRepository = new DAL_ProjectCatelogy();
            ProductCatelogyRepository = new DAL_ProductCatelogy();
            AdvertRepository = new DAL_Advert();
            LinkWebsiteRepository = new DAL_LinkWebsite();
            ProjectRepository = new DAL_Project();
            ProductRepository = new DAL_Product();
            WorksRepository = new DAL_Work();
            PartnerRepository = new DAL_Partner();
            AttachCatelogyRepository = new DAL_AttachCatelogy();
        }

        public ActionResult Index()
        {
            var ListMenuItem = CatelogyRepositpry.getListMenuItem();
            var listtop1project = ProjectRepository.getListTop1Project();
            var listop8project = ProjectRepository.getTop8Project();
            var listtop2Press = pressRepository.getListTop2Press();
            var listtop2Product = ProductRepository.getTop2Product();
            var listPartner = PartnerRepository.getListPartner();
           

            ViewData["listtop1project"] = listtop1project;
            ViewData["listop8project"] = listop8project;
            ViewData["listtop2Press"] = listtop2Press;
            ViewData["listtop2Product"] = listtop2Product;
            ViewData["listPartner"] = listPartner;

            return View();
 
        }

        public ActionResult About()
        {
            return View();
        }

        public ActionResult defaut()
        {
            var list = pressRepository.getListPressShow();
            return View(list);
        }

        public ActionResult testList()
        {
           var list = pressRepository.getListPress();
           return View(list);
        }


        public ActionResult Introduce()
        {
            return View();
        }
        public ActionResult NavigationUserControl()
        {
            var listProjectCatelogy = ProjectCatelogyRepository.getListProjectCatelogy();
            var listProductCatelogy = ProductCatelogyRepository.getListProductCatelogy();
            var listAdvert = AdvertRepository.getListAdvert();
            var listLinkWebsite = LinkWebsiteRepository.getListLinkWebsite();
            var listAdvertIma = AdvertRepository.getTopnAdvert(2);
            var listDownload = AttachCatelogyRepository.getListAttachCatelogy();
            ViewData["listProjectCatelogy"] = listProjectCatelogy;
            ViewData["listProductCatelogy"] = listProductCatelogy;
            ViewData["listAdvert"] = listAdvert;
            ViewData["listAdvertIma"] = listAdvertIma;
            ViewData["listLinkWebsite"] = listLinkWebsite;
            ViewData["listDownload"] = listDownload;
            return View();
      
        }
        public ActionResult HeadSlideUserControl()
        {
            var listWork = WorksRepository.getTopNWork(4);
            ViewData["listWork"] = listWork;
            return View();
        }
        public ActionResult MenuUserControl()
        {
            var listProjectCatelogy = ProjectCatelogyRepository.getListProjectCatelogy();
            var listProductCatelogy = ProductCatelogyRepository.getListProductCatelogy();
            ViewData["listProjectCatelogy"] = listProjectCatelogy;
            ViewData["listProductCatelogy"] = listProductCatelogy;
            return View();
        }
        public ActionResult MenuLeft()
        {
            var listProjectCatelogy = ProjectCatelogyRepository.getListProjectCatelogy();
            var listProductCatelogy = ProductCatelogyRepository.getListProductCatelogy();
            var listAdvert = AdvertRepository.getListAdvert();
            var listLinkWebsite = LinkWebsiteRepository.getListLinkWebsite();
            ViewData["listProjectCatelogy"] = listProjectCatelogy;
            ViewData["listProductCatelogy"] = listProductCatelogy;
            ViewData["listAdvert"] = listAdvert;
            ViewData["listLinkWebsite"] = listLinkWebsite;
            return View();

        }

    }
}
